<template>
  <div class="app-container">
    <div class="block">
      <el-row :gutter="20">
        <el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="6">
          <el-input v-model="listQuery.name" size="mini" placeholder="请输入工作项" />
        </el-col>
        <el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="6">
          <el-button type="success" size="mini" icon="el-icon-search" @click.native="search">{{
            $t('button.search')
          }}</el-button>
          <el-button type="primary" size="mini" icon="el-icon-refresh" @click.native="reset">{{
            $t('button.reset')
          }}</el-button>
        </el-col>
      </el-row>
      <br>
      <el-row>
        <el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="6">
          <el-button v-permission="['/accountPwd/add']" type="success" size="mini" icon="el-icon-plus"
            @click.native="add">{{ $t('button.add') }}</el-button>
        </el-col>
      </el-row>
    </div>

    <el-table v-loading="listLoading" :data="list" element-loading-text="Loading" :header-cell-style="{ background: '#f5f5f7' }" border fit highlight-current-row
      @current-change="handleCurrentChange">
      <el-table-column :xs="3" :sm="3" :md="3" :lg="3" :xl="3" prop="name" sortable label="工作项">
      </el-table-column>
      <el-table-column :xs="3" :sm="3" :md="3" :lg="3" :xl="3" prop="websiteUrl" label="网址地址"
        :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <el-link v-if="scope.row.websiteUrl.includes('http')" :href="scope.row.websiteUrl" type="primary"
            target="_blank">{{ scope.row.websiteUrl }}</el-link>
          <el-link v-if="!scope.row.websiteUrl.includes('http')" :href="'https://' + scope.row.websiteUrl"
            type="primary" target="_blank">{{ scope.row.websiteUrl }}</el-link>
          <!-- <a :href='scope.row.websiteUrl'    target="_blank"> {{ scope.row.websiteUrl }}</a> -->
        </template>
      </el-table-column>
      <el-table-column :xs="3" :sm="3" :md="3" :lg="3" :xl="3" prop="accountName" label="登陆账号">
      </el-table-column>
      <el-table-column :xs="3" :sm="3" :md="3" :lg="3" :xl="3" prop="currentState" sortable label="状态">
      </el-table-column>
      <el-table-column :xs="3" :sm="3" :md="3" :lg="3" :xl="3" prop="description" label="备注">
        <!-- <template slot-scope="scope">
          {{ scope.row.linkman }}
        </template> -->
      </el-table-column>

      <el-table-column fixed="right" label="操作" :xs="6" :sm="6" :md="6" :lg="6" :xl="6"
        class-name="small-padding fixed-width">
        <template slot-scope="{row}">
          <el-button v-permission="['/accountPwd/edit']" type="primary" size="mini" icon="el-icon-edit"
            @click="edit(row)">{{ $t('button.edit') }}</el-button>
          <!-- <el-button v-permission="['/accountPwd/delete']" type="danger" size="mini" icon="el-icon-delete" @click.native="remove(row)">{{ $t('button.delete') }}</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :xs="24" :sm="24" :md="24" :lg="24" :xl="24" background
      layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 20, 50, 100, 500]"
      :page-size="listQuery.pageSize" :total="total" @size-change="changeSize" @current-change="fetchPage"
      @prev-click="fetchPrev" @next-click="fetchNext" />

    <el-dialog :title="formTitle" :visible.sync="formVisible" width="70%">
      <el-form ref="form" :model="form" :rules="rules" label-width="30%">
        <el-row>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="工作项" prop="name">
              <el-input v-model="form.name" minlength="1" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="网址地址" prop="websiteUrl">
              <el-input v-model="form.websiteUrl" minlength="1" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="登陆账号" prop="accountName">
              <el-input v-model="form.accountName" minlength="1" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="登陆密码" prop="password">
              <el-input v-model="form.password" minlength="1" />
            </el-form-item>
          </el-col>
          <!-- <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="状态" prop="currentState">
              <el-input v-model="form.currentState" minlength="1" />
            </el-form-item>
          </el-col> -->

          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="开始时间" prop="startTime">
              <!-- <el-input v-model="form.pettyCashTime" minlength="1" /> -->
              <el-date-picker v-model="form.startTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="结束时间" prop="endTime">
              <!-- <el-input v-model="form.pettyCashTime" minlength="1" /> -->
              <el-date-picker v-model="form.endTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="提醒时间" prop="reminderTime">
              <!-- <el-input v-model="form.reminderTime" />
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option> -->
              <el-date-picker v-model="form.reminderTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="状态" prop="currentState">
              <el-select v-model="form.currentState" style="display:block;" placeholder="请选择">
                <el-option v-for="item in allCurrentState" :key="item" :label="item" :value="item" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="消息类型" prop="msgReminderType">
              <el-select  v-model="form.msgReminderType" @change="selectMsgReminderType(form.msgReminderType)"
                style="display:block;" placeholder="请选择">
                <!-- <el-option v-for="item in allMsgReminderType" :key="item.id" :label="item.name" :value="item.id" /> -->
                <el-option
                  label="企业微信"
                  value="企业微信">
                </el-option>
                <el-option
                  label="钉钉"
                  value="钉钉">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="消息模板" prop="reminderTemplate">
              <el-select v-model="form.reminderTemplate" style="display:block;" placeholder="请选择">
                <el-option v-for="item in allReminderTemplate" :key="item.id" :label="item.name"
                  :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
            <el-form-item label="备注" prop="description">
              <el-input v-model="form.description" minlength="1" />
            </el-form-item>
          </el-col>
          <!-- <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
            <el-button type="primary" @click="save">{{ $t('button.submit') }}</el-button>
            <el-button @click.native="formVisible = false">{{ $t('button.cancel') }}</el-button>
          </el-col> -->
        </el-row>
        <el-row>
          <el-col :xs="6" :sm="6" :md="6" :lg="3" :xl="3">&nbsp;&nbsp;

          </el-col>
          <el-col :xs="18" :sm="18" :md="18" :lg="21" :xl="21">&nbsp;&nbsp;
            <el-button type="primary" @click="save">{{ $t('button.submit') }}</el-button>
            <el-button @click.native="formVisible = false">{{ $t('button.cancel') }}</el-button>
          </el-col>
          <!-- <el-form-item>
            
          </el-form-item> -->

        </el-row>

      </el-form>
    </el-dialog>
  </div>
</template>

<script src="./accountPwd.js"></script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";

.el-select {
    width: 100%;
}
#el-cascader {
    width: 100%;
}

//  .el-dialog__wrapper .el-dialog {
//       width: 300px !important;
//       .el-dialog__body{
//         padding: 10px 20px!important;
//         .el-form-item__label{
//           width: 68px!important;
//         }
//         .el-select,.el-input{
//           width: 180px!important;
//         }
//       }
//     }
</style>
